<?php
defined('_JEXEC') or die('Restricted access');
$app = JFactory::getApplication();
$input = $app->input;
$item  = $input->getArray();
?>
<div class="res-title-rg">
    <span class="fl pos-icon text-c"><i class="revenue"></i></span>
    <div class="title-info">
        <h2 class="fontsize20">Daily Revenue</h2>
        <p><a href="#">Home</a>&nbsp;/&nbsp;Revenue&nbsp;/&nbsp;Daily Revenue</p>
    </div>
</div>
<div class="ws-content pdall15">
    <?php if ($item['times']): ?>
        <div id="main" style="height:520px;"></div>
    <?php else: ?>
        <p class="ws-tips">No report data found.</p>
    <?php endif; ?>
</div>
<script type="text/javascript">
    var colors = ['#5793f3', '#d14a61', '#675bba'];
    var chart = echarts.init(document.getElementById('main'));
    option = {
        tooltip : {
            trigger: 'axis',
            axisPointer : {
                type : 'shadow'
            }
        },
        toolbox: {
            feature: {
                dataView: {show: true, readOnly: false},
                restore: {show: true},
                saveAsImage: {show: true}
            }
        },
        grid: {
            left: '3%',
            right: '4%',
            bottom: '3%',
            containLabel: true
        },
        xAxis: [
            {
                type: 'category',
                axisTick: {
                    alignWithLabel: true
                },
                data: <?php echo json_encode($item['times'])?>
            }
        ],
        yAxis: [
            {
                type: 'value',
                name: 'Revenue',
                position: 'left',
                axisLine: {
                    lineStyle: {
                        color: colors[2]
                    }
                },
                axisLabel: {
                    formatter: '{value} '
                }
            }
        ],
        series: [

            <?php
            //堆积图
            $j = 0;
            foreach($item['seriesarr'] as $key => $value):
            $j++;
            ?>
            {
                name:'<?php echo $key;?>',
                type: 'bar',
                stack: 'total',
                label: {
                    normal: {
                        show: true,
                        position: 'insideRight'
                    }
                },
                data: <?php echo json_encode($value)?>
            },
            <?php endforeach;?>
            {
                type:'line',  //折线
                data: <?php echo json_encode(array_column($item['drevenueArray']['data'],'value'))?>
            }
        ]
    };
    chart.setOption(option);
</script>


